package com.xiong.ai.result;

import lombok.Data;

import java.io.Serial;
import java.io.Serializable;

/**
 * @program: ai
 * @description:
 * @author: Mr.熊
 * @create: 2024-05-31 10:43
 **/
@Data
public class ResBody<T> implements Serializable {

    @Serial
    private static final long serialVersionUID = 820592085459570906L;

    public static final String SUCCESS_CODE = "000000";

    private String code;

    private String msg;

    private T body;

    public ResBody() {
    }

    public ResBody(String code, String msg, T body) {
        this.code = code;
        this.msg = msg;
        this.body = body;
    }

    public static <T> ResBody<T> ok() {
        ResBody<T> res = new ResBody<>();
        res.setCode(SUCCESS_CODE);
        res.setMsg("成功");
        res.setBody(null);
        return res;
    }

    public static <T> ResBody<T> ok(T body) {
        ResBody<T> res = new ResBody<>();
        res.setCode(SUCCESS_CODE);
        res.setMsg("成功");
        res.setBody(body);
        return res;
    }

}
